﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EVB.Collections.Immutable
{
    public static class Extensions
    {
        public static Stack<T> Reverse<T>(this Stack<T> stack)
        {
            var reversed = Stack<T>.Empty;

            for (var f = stack; !f.IsEmpty; f = f.Pop())
                reversed = reversed.Push(f.Peek);

            return reversed;
        }
    }
}